import request from '../utils/request';

/**
 * 用户登录
 * type 1 小程序 2 手机号, openid, nickname, avatar, mobile
 */
export function register(data) {
  return request({
    url: 'user/register',
    method: 'post',
    data: data,
  });
}

/**
 * 用户更新
 * nickname, avatar
 */
export function update(data) {
  return request({
    url: 'user/update',
    method: 'put',
    data: data,
  });
}

/**
 * 小程序用户信息解密
 * encryptedData, iv, key
 */
export function decryptData(data) {
  return request({
    url: 'user/decrypt-data',
    method: 'post',
    data: data,
  });
}

/**
 * 获取session-key
 * code
 */
export function getSessionKey(data) {
  return request({
    url: 'user/get-session-key',
    method: 'post',
    data: data,
  });
}
export function loginLog(data) {
  return request({
    url: 'login-log/add',
    method: 'post',
    data: data,
  });
}

/**
 * 获取用户信息
 * id
 */
export function getUserInfo(data) {
  return request({
    url: 'user/info',
    method: 'post',
    data: data,
  });
}
export function getMemberPic(data) {
  return request({
    url: 'member-pic/lists',
    method: 'get',
    data: data,
  });
}
export function getMemberword(data) {
  return request({
    url: 'word/lists',
    method: 'get',
    data: data,
  });
}

/**
 * 绑定手机号
 * encryptedData iv key
 */
export function bindMobile(data) {
  return request({
    url: 'user/bind-phone',
    method: 'post',
    data: data,
  });
}

/**
 * 修改昵称
 * nickname
 */
export function updateNickname(data) {
  return request({
    url: 'user/edit-nickname',
    method: 'post',
    data: data,
  });
}

/**
 * 查询某用户的业绩
 * id start_time end_time
 */
export function userPerformance(data) {
  return request({
    url: 'user/performance',
    method: 'post',
    data: data,
  });
}

/**
 * 查询下级代理
 * id
 */
export function userLowerAgent(data) {
  return request({
    url: 'user/lower-agent',
    method: 'post',
    data: data,
  });
}

/**
 * 查询所有顶级代理
 */
export function topAgent(data) {
  return request({
    url: 'user/top-agent',
    method: 'post',
    data: data,
  });
}

/**
 * 扫描获取购物卡信息
 * card_no
 */
export function getCardInfo(data) {
  return request({
    url: 'shop-card/admin-scan',
    method: 'post',
    data: data,
  });
}
export function memberCardInfo(data) {
  return request({
    url: 'member-card/admin-scan',
    method: 'post',
    data: data,
  });
}
/**
 * 超级管理员扫描后分配给某一级代理 全部出库
 * card_nos id
 */
export function adminAllot(data) {
  return request({
    url: 'shop-card/allot',
    method: 'post',
    data: data,
  });
}

/**
 * 超级管理员入库
 * card_no
 */
export function adminInputCard(data) {
  return request({
    url: 'shop-card/return-card',
    method: 'post',
    data: data,
  });
}

/**
 * 获取优惠券
 
 */
export function getUserRoll(data) {
  return request({
    url: 'coupon/list',
    method: 'get',
    data: data,
  });
}

export function getUserRollTimeOut(data) {
  return request({
    url: 'coupon/expired/list',
    method: 'get',
    data: data,
  });
}
//优惠卷
export function couponBind(data) {
  return request({
    url: 'goods-coupon/bind',
    method: 'post',
    data: data,
  });
}
/**
 * 活动吃鱼接口
 */
export function canEatFinsh() {
  return request({
    url: 'activity/apply',
    method: 'post',
  });
}
//视频
export function getvideolist(data) {
  return request({
    url: 'video/detail',
    method: 'get',
    data: data,
  });
}
//代理商备注
export function agentInfoCreate(data) {
  return request({
    url: 'agent-info/create',
    method: 'post',
    data: data,
  });
}
//代理商备注
export function agentInfoEdit(data) {
  return request({
    url: 'agent-info/edit',
    method: 'post',
    data: data,
  });
}
//代理商备注
export function agentInfoDetail(data) {
  return request({
    url: 'agent-info/detail',
    method: 'post',
    data: data,
  });
}
//代理商数据统计
export function agentStatistic(data) {
  return request({
    url: 'user/agent-statistic',
    method: 'post',
    data: data,
  });
}
//代理商定制图片
export function getcustomizepic(data) {
  return request({
    url: 'user/get-customize-pic',
    method: 'get',
    data: data,
  });
}